package com.hub.transform;

import com.hub.entity.MySensor;
import com.hub.entity.SensorReading;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class TransformBaseFromCustom {

    public static void main(String[] args) throws Exception {

        // 环境准备
        StreamExecutionEnvironment executionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment();

        // 添加数据源：自定义数据源
        DataStreamSource<SensorReading> dataStreamSource = executionEnvironment.addSource(new MySensor());


        // 分组找出最大
        DataStream<SensorReading> template = dataStreamSource.keyBy(SensorReading::getId).maxBy("template");

        template.print("max template : ");

        // 打印任务
//        dataStreamSource.print("from_custom");

        // 执行
        executionEnvironment.execute();


    }
}
